package org.jeecgframework.web.util;

import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;

/**
 * Created by 大伟 on 2016/12/19.
 * Description
 */
public enum SectionEnum {
    FIRST(1,"第一季度"),
    SECOND(2,"第二季度"),
    THIRD(3,"第三季度"),
    FOURTH(4,"第四季度");

    public int index;

    public String msg;

    SectionEnum(int index,String msg){
        this.index = index;
        this.msg = msg;
    }


    public static SectionEnum valueOfIndex(int index){
        for(SectionEnum sec : SectionEnum.values()){
            if(sec.index == index){
                return sec;
            }
        }
        return SectionEnum.FIRST;
    }

    public static List<SectionEnum> valueOfRestSection(){
        SectionEnum se = getCurrentSection();
        List<SectionEnum> restSections = new ArrayList<SectionEnum>();
        for(SectionEnum sec : SectionEnum.values()){
            if(sec.index > se.index){
                restSections.add(sec);
            }
        }
        return restSections;
    }

    public static SectionEnum getCurrentSection(){
        Calendar c1 = Calendar.getInstance();
        int month = c1.get(Calendar.MONTH)+1;
        int currentSection = month/3 ;
        if(month%3 > 0){
            currentSection++;
        }
        return SectionEnum.valueOfIndex(currentSection);
    }

}
